<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>CSS Hover Magic</title>
  <style>
    :root {
      --bg: #f8fafc;
      --txt: #1e293b;
      --card: #ffffff;
      --sh: rgba(0,0,0,0.08);
      --accent: #6366f1;
      --tog-bg: #cbd5e1;
      --handle: #ffffff;
    }
    [data-theme="dark"] {
      --bg: #0f172a;
      --txt: #f1f5f9;
      --card: #1e293b;
      --sh: rgba(0,0,0,0.3);
      --accent: #a78bfa;
      --tog-bg: #475569;
      --handle: #f1f5f9;
    }
    * {
      margin: 0;
      padding: 0;
      box-sizing: border-box;
    }
    body {
      background: var(--bg);
      color: var(--txt);
      font-family: 'Segoe UI', system-ui, sans-serif;
      line-height: 1.6;
      transition: all 0.4s ease;
      padding: 2rem 1rem;
    }
    h1 {
      text-align: center;
      margin-bottom: 2rem;
      font-size: 2.5rem;
      font-weight: 700;
      background: linear-gradient(135deg, var(--accent), #8b5cf6);
      -webkit-background-clip: text;
      background-clip: text;
      color: transparent;
    }
    .header {
      display:flex;
      justify-content:space-between;
      align-items:center;
      flex-wrap:wrap;
      gap:1rem;
      margin-bottom:2rem;
      padding: 0 4rem;
    }
    .toggle-container {
      display: flex;
      justify-content: center;
      align-items: center;
      gap: 1rem;
      margin-bottom: 3rem;
      flex-wrap: wrap;
    }
    .toggle-wrapper {
      display: flex;
      align-items: center;
      gap: 0.75rem;
      font-weight: 500;
      font-size: 1rem;
    }
    .toggle-label {
      position: relative;
      width: 60px;
      height: 32px;
    }
    .toggle-label input {
      opacity: 0;
      width: 0;
      height: 0;
    }
    .slider {
      position: absolute;
      cursor: pointer;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      background: var(--tog-bg);
      transition: 0.4s;
      border-radius: 32px;
    }
    .slider:before {
      position: absolute;
      content: "";
      height: 26px;
      width: 26px;
      left: 3px;
      bottom: 3px;
      background: var(--handle);
      transition: 0.4s;
      border-radius: 50%;
      box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    }
    input:checked + .slider {
      background: var(--accent);
    }
    input:checked + .slider:before {
      transform: translateX(28px);
    }
    .grid {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
      gap: 2rem;
      max-width: 1200px;
      margin: 0 auto;
    }
    .card {
      background: var(--card);
      padding: 5rem 5rem;
      border-radius: 20px;
      box-shadow: 0 10px 30px var(--sh);
      text-align: center;
      cursor: pointer;
      position: relative;
      overflow: hidden;
      min-height: 120px;
      display: flex;
      align-items: center;
      justify-content: center;
      font-family: 'Courier New', monospace;
      font-size: 2rem;
      font-weight: bold;
      transition: all 0.3s ease;
      border: 1px solid rgba(255,255,255,0.2);
    }
    .card:hover {
      transform: translateY(-8px);
      box-shadow: 0 20px 40px var(--sh);
      border-color: var(--accent);
    }
    /* Hide text until hover */
    .card > div {
      opacity: 0;
      transition: opacity 0.3s ease;
    }
    .card:hover > div {
      opacity: 1;
    }
    /* Typewriter */
    .typewriter {
      width: 0;
      white-space: nowrap;
      overflow: hidden;
      border-right: 3px solid transparent;
    }
    .card:hover .typewriter {
      width: 11ch;
      border-color: var(--txt);
      animation: typing 2.5s steps(11) forwards, blink 0.75s infinite;
    }
    @keyframes typing { from { width: 0; } to { width: 11ch; } }
    @keyframes blink { 50% { border-color: transparent; } }
    /* Rotate Letters */
    .rotate span { display: inline-block; opacity: 0; }
    .card:hover .rotate span { 
      opacity: 1; 
      animation: rotateLetter 0.8s ease-out forwards; 
    }
    .rotate span:nth-child(n) { animation-delay: calc(0.05s * var(--n)); }
    @keyframes rotateLetter {
      0% { transform: rotateY(0deg); opacity: 0; }
      50% { transform: rotateY(180deg); }
      100% { transform: rotateY(360deg); opacity: 1; }
    }
    /* Bounce */
    .bounce span { 
      display: inline-block; 
      opacity: 0; 
      transform: translateY(30px); 
    }
    .card:hover .bounce span { 
      opacity: 1; 
      animation: bounce 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards; 
    }
    .bounce span:nth-child(1) { animation-delay: 0.1s; }
    .bounce span:nth-child(2) { animation-delay: 0.15s; }
    .bounce span:nth-child(3) { animation-delay: 0.2s; }
    .bounce span:nth-child(4) { animation-delay: 0.25s; }
    .bounce span:nth-child(5) { animation-delay: 0.3s; }
    .bounce span:nth-child(6) { animation-delay: 0.35s; }
    @keyframes bounce {
      0% { transform: translateY(30px); }
      60% { transform: translateY(-10px); }
      100% { transform: translateY(0); }
    }
    /* Slide In */
    .slide { opacity: 0; transform: translateX(-50px); }
    .card:hover .slide {
      opacity: 1;
      transform: translateX(0);
      transition: all 0.6s ease-out;
    }
    /* Rainbow */
    .rainbow { opacity: 0; }
    .card:hover .rainbow {
      opacity: 1;
      background: linear-gradient(45deg, #ff0000, #ff8000, #ffff00, #00ff00, #00ffff, #0000ff, #ff00ff, #ff0000);
      background-size: 400% 400%;
      -webkit-background-clip: text;
      background-clip: text;
      color: transparent;
      animation: rainbow 3s linear infinite;
    }
    @keyframes rainbow {
      0% { background-position: 0% 50%; }
      100% { background-position: 400% 50%; }
    }
    /* Pulse */
    .pulse { opacity: 0; }
    .card:hover .pulse {
      opacity: 1;
      animation: pulse 1.5s ease-in-out infinite;
    }
    @keyframes pulse {
      0%, 100% { transform: scale(1); }
      50% { transform: scale(1.1); }
    }
    @media (max-width: 768px) {
      .grid {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
        gap: 1.5rem;
      }
      h1 { font-size: 2rem; }
      body { padding: 1rem; }
    }
  </style>
</head>
<body>
  <div class="header">
    <h1> Hover to see the magic </h1>
    <div class="toggle-container">
      <label class="toggle-wrapper">
        <div class="toggle-label">
          <input type="checkbox" id="themeToggle" onchange="document.documentElement.setAttribute('data-theme', this.checked ? 'dark' : 'light')">
          <span class="slider"></span>
        </div>
      </label>
    </div>
  </div>
  <div class="grid">
    <div class="card"><div class="typewriter">Typewriter</div></div>
    <div class="card"><div class="rotate">
      <span style="--n:1">R</span><span style="--n:2">o</span><span style="--n:3">t</span><span style="--n:4">a</span><span style="--n:5">t</span><span style="--n:6">e</span>
    </div></div>
    <div class="card"><div class="bounce">
      <span>B</span><span>o</span><span>u</span><span>n</span><span>c</span><span>e</span>
    </div></div>
    <div class="card"><div class="slide">Slide In</div></div>
    <div class="card"><div class="rainbow">Rainbow</div></div>
    <div class="card"><div class="pulse">Pulse</div></div>
  </div>
</body>
</html>
